package Processes;

import threadedSimulator.Cpu;

/**
 * Runs this process when a keyboard event is fired. 
 * @author Harris
 */
public class KeyboardProcess extends Processes{

    /**
     * keeps track of the inner for loop.
     */
    int my_count = 0;
    /**
     * the string that is being worked on.
     */
    String output;
    /**
     * constructor
     * @param the_cpu the cpu
     * @param the_numberof_pro_con the incoming string for keyboard IO
     */
	public KeyboardProcess(Cpu the_cpu, String the_numberof_pro_con) {
		super(the_cpu, the_numberof_pro_con, "Keyboard");
                output = the_numberof_pro_con;
		my_priority = 1;
	}
    

     /**
      * run method that adds the string to itself and the letter a repeatedly.
      */
    @Override
    public void run() {
        while (running && my_current_index <= MAX_VALUE) {
            running = true;
            while (my_count < 10000 && can_run && my_current_index <= MAX_VALUE) { //my_count lets us go back where we left off.
                output += output + "a";
                my_count++;
            }
            my_current_index++;
            if (my_current_index == MAX_VALUE) { //checks to see if a whole loop has been excecuted and starts over.
            	//has_finished = true;
                my_current_index = 0;
                output = "";
                running = false;
            }	
            
        }
    }


}
